package com.jt.web.comtroller;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.jt.pojo.ItemDesc;
import com.jt.util.ObjectMapperUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JSONPController {
    @RequestMapping("/web/testJSONP")
    public JSONPObject jsonp(String callback){
        ItemDesc itemDesc = new ItemDesc();
        itemDesc.setItemId(100L).setItemDesc("API测试成功");
        return new JSONPObject(callback,itemDesc);
    }
//    public String jsonp(String callback){
//        ItemDesc itemDesc = new ItemDesc();
//        itemDesc.setItemId(100L).setItemDesc("测试成功");
//        String json = ObjectMapperUtil.toJson(itemDesc);
//        return callback+"("+json+")";
//    }
}
